; atoms called from the UI

atom(script) saveUI()
{
	if ${ISXVG.ConnectionState.Find[IN_GAME]} 
    call xmlSave
}

atom(script) EpicSet()
{
  echo ~~~ setting Epic ~~~ ${epicSlot}
  if ${epicSlot.Length.Equal[0]} || ${epicSlot.Equal[Ranged]} || ${epicSlot.Equal[NULL]}
  {
    if ${Me.Inventory[CurrentEquipSlot, Two Hands](exists)}
    {
      epicSlot:Set[Two Hands]
      if ${Me.Inventory[CurrentEquipSlot,"Two Hands"].IsHotkeyed}
        burnEpicName:Set[${Me.Inventory[CurrentEquipSlot,"Two Hands"].Name}]
    }
    elseif ${Me.Inventory[CurrentEquipSlot, Primary](exists)}
    {
      epicSlot:Set[Primary]
      if ${Me.Inventory[CurrentEquipSlot, Primary].IsHotkeyed}
        burnEpicName:Set[${Me.Inventory[CurrentEquipSlot, Primary].Name}]
    }
  }
  elseif ${epicSlot.Equal[Two Hands]} || ${epicSlot.Equal[Secondary]}
  {
    if ${Me.Inventory[CurrentEquipSlot, Ranged](exists)}
    {
      epicSlot:Set[Ranged]
      if ${Me.Inventory[CurrentEquipSlot, Ranged].IsHotkeyed}
        burnEpicName:Set[${Me.Inventory[CurrentEquipSlot, Ranged].Name}]
    }
  }
  else
  {
    if ${Me.Inventory[CurrentEquipSlot,"Secondary"](exists)}
    {
      epicSlot:Set[Secondary]
      if ${Me.Inventory[CurrentEquipSlot, Secondary].IsHotkeyed}
        burnEpicName:Set[${Me.Inventory[CurrentEquipSlot,"Secondary"].Name}]
    }
  }
}

atom(script) SpellLineMobHealsToSelection(string spellLine)
{
  echo ~~~ Mob Heals To Spell Line Selection ~~~ ${spellLine}
  UIElement[MobHealsToList@CustomMobsFrame@Mobs@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg]:ClearItems
  variable iterator mobIter
  variable iterator healIter
  LavishSettings[MobDict]:GetSetIterator[mobIter]
  if ${mobIter:First(exists)}
  {
    echo ### found the first iterator so looping through ###
    do
    {
      mobIter.Value:GetSettingIterator[healIter]
      if ${healIter:First(exists)}
      {
        do
        {
          echo ${mobIter.Key}, ${healIter.Key}, ${healIter.Value}, ${spellLine.Equal[${healIter.Value}]}
          if ${spellLine.Equal[${healIter.Value}]}
            UIElement[MobHealsToList@CustomMobsFrame@Mobs@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg]:AddItem[${mobIter.Key}]  
        }
        while ${healIter:Next(exists)}
      }
    }
    while ${mobIter:Next(exists)}
  }
}

atom(script) MobHealsToSave()
{
  if !${UIElement[MobHealsToCombo@CustomMobsFrame@Mobs@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg].SelectedItem.Text(exists)}
    return
  if !${UIElement[MobsEngagedCombo@CustomMobsFrame@Mobs@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg].SelectedItem.Text(exists)}
    return
  variable string mobName
  variable string spellLine
  mobName:Set[${UIElement[MobsEngagedCombo@CustomMobsFrame@Mobs@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg].SelectedItem.Text}]
  spellLine:Set[${UIElement[MobHealsToCombo@CustomMobsFrame@Mobs@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg].SelectedItem.Text}]
  if !${LavishSettings[MobDict].FindSet[${mobName}](exists)}
    LavishSettings[MobDict]:AddSet[${mobName}]
  if !${LavishSettings[MobDict].FindSet[${mobName}].FindSetting[HealsTo](exists)}
    LavishSettings[MobDict].FindSet[${mobName}]:AddSetting["HealsTo", ${spellLine}]
  else
  {
    LavishSettings[MobDict].FindSet[${mobName}].FindSetting["HealsTo"]:Remove
    LavishSettings[MobDict].FindSet[${mobName}]:AddSetting["HealsTo", ${spellLine}]
  }
  UIElement[MobHealsToList@CustomMobsFrame@Mobs@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg]:AddItem[${mobName}]
}

atom(script) Commands(string cmd)
{
  if ${cmd.Equal[asst]}
  {
    ;VGExecute /group \"<red=>###@@@ ASSIST me on ${Me.Target.Name} @@@### \"
    ;VGExecute /raid \"<red=>###@@@ ASSIST me on ${Me.Target.Name} @@@### \"
    relay "all other" Script[ezvg]:ExecuteAtom[EZVGCommands,"ASSIST"]
  }
  elseif ${cmd.Equal[run]}
  {
    ;VGExecute /group \"<green=>###@@@ Let's get this party STARTED! @@@### \"
    ;VGExecute /raid \"<green=>###@@@ Let's get this party STARTED! @@@### \"
    relay "all other" Script[ezvg]:ExecuteAtom[EZVGCommands,"RUN"]
  }
  elseif ${cmd.Equal[pause]}
  {
    ;VGExecute /group \"<green=>###@@@ I need a BREAK!!! @@@### \"
    ;VGExecute /raid \"<green=>###@@@ I need a BREAK!!! @@@### \"
    relay "all other" Script[ezvg]:ExecuteAtom[EZVGCommands,"PAUSE"]
  }
  elseif ${cmd.Equal[camp]}
  {
    ;VGExecute /group \"<blue=>###@@@ I am going to LOG OUT for a bit. @@@### \"
    ;VGExecute /raid \"<blue=>###@@@ I am going to LOG OUT for a bit. @@@### \"
    relay "all other" Script[ezvg]:ExecuteAtom[EZVGCommands,"LOG OUT"]
  }
}

atom(script) CommandBarMaintenance()
{
  if ${UIElement[EZVGCommands].Visible}
  {
    UIElement[EZVGCommands]:Hide
    UIElement[ezvg].FindUsableChild[Minimize,button]:LeftClick
  }
  else
  {
    UIElement[EZVGCommands]:Show
    UIElement[ezvg].FindUsableChild[Minimize,button]:LeftClick
  }
    
}

atom(script) AddHuntWaypoint(int WP)
{
  huntWP[${WP}]:Set[${Me.X}, ${Me.Y}]
  variable int wpX=${Me.X}
  variable int wpY=${Me.Y}
  if ${wpX}!=0 && ${wpY}!=0
    UIElement[WP${WP}Button@HuntLocFrame@Loc@HuntTabs@HuntFrame@Hunt@EZVGTabs@ezvg]:SetText["( ${Math.Calc[${wpX}].Int} , ${Math.Calc[${wpY}].Int} )"]
  elseif ${WP}==1
    UIElement[WP${WP}Button@HuntLocFrame@Loc@HuntTabs@HuntFrame@Hunt@EZVGTabs@ezvg]:SetText["C A M P"]
  else
    UIElement[WP${WP}Button@HuntLocFrame@Loc@HuntTabs@HuntFrame@Hunt@EZVGTabs@ezvg]:SetText["WP_${WP} - OPEN"]
   ;echo "Adding ${WP} at ${Me.Location}"
}

atom(script) ClearHuntWaypoint(int WP)
{
  huntWP[${WP}]:Set[0, 0]
  UIElement[WP${WP}RangeSliderValue@HuntLocFrame@Loc@HuntTabs@HuntFrame@Hunt@EZVGTabs@ezvg]:SetText[${huntDist[${WP}]}]
  if ${WP}==1
    UIElement[WP${WP}Button@HuntLocFrame@Loc@HuntTabs@HuntFrame@Hunt@EZVGTabs@ezvg]:SetText["C A M P"]
  else
    UIElement[WP${WP}Button@HuntLocFrame@Loc@HuntTabs@HuntFrame@Hunt@EZVGTabs@ezvg]:SetText["WP_${WP} - OPEN"]
   ;echo "Removing ${WP}"
}

atom(script) changeHuntDist(int WP, int D)
{
  huntDist[${WP}]:Set[${D}]
  UIElement[WP${WP}RangeSliderValue@HuntLocFrame@Loc@HuntTabs@HuntFrame@Hunt@EZVGTabs@ezvg]:SetText[${huntDist[${WP}]}]
  ;echo changing huntDist on wp ${WP} to dist ${D}
}

atom(script) CustomAbilRotSelection(string abilRot)
{
  UIElement[CustomAbilCombo@CustomAbilitiesRotationsFrame@Rotations@CustomAbilitiesTabs@CustomAbilitiesFrame@Abilities@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg]:ClearItems
  variable iterator abilIter
  variable string abilType
  variable int iterCnt
  switch ${abilRot}
  {
      case buffRot
        UIElement[CustomRotList@CustomAbilitiesRotationsFrame@Rotations@CustomAbilitiesTabs@CustomAbilitiesFrame@Abilities@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg]:ClearItems  
        buffRot:GetSettingIterator[abilIter]
        abilType:Set["bene"]
        break
      case combatBuffRot
        UIElement[CustomRotList@CustomAbilitiesRotationsFrame@Rotations@CustomAbilitiesTabs@CustomAbilitiesFrame@Abilities@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg]:ClearItems  
        combatBuffRot:GetSettingIterator[abilIter]
        abilType:Set["all"]
        break
      case groupBuffRot
        UIElement[CustomRotList@CustomAbilitiesRotationsFrame@Rotations@CustomAbilitiesTabs@CustomAbilitiesFrame@Abilities@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg]:ClearItems  
        groupBuffRot:GetSettingIterator[abilIter]
        abilType:Set["bene"]
        break
      case healBigRot
        UIElement[CustomRotList@CustomAbilitiesRotationsFrame@Rotations@CustomAbilitiesTabs@CustomAbilitiesFrame@Abilities@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg]:ClearItems  
        healBigRot:GetSettingIterator[abilIter]
        abilType:Set["bene"]
        break
      case healMedRot
        UIElement[CustomRotList@CustomAbilitiesRotationsFrame@Rotations@CustomAbilitiesTabs@CustomAbilitiesFrame@Abilities@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg]:ClearItems  
        healMedRot:GetSettingIterator[abilIter]
        abilType:Set["bene"]
        break
      case healEmgRot
        UIElement[CustomRotList@CustomAbilitiesRotationsFrame@Rotations@CustomAbilitiesTabs@CustomAbilitiesFrame@Abilities@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg]:ClearItems  
        healEmgRot:GetSettingIterator[abilIter]
        abilType:Set["bene"]
        break
      case healHotRot
        UIElement[CustomRotList@CustomAbilitiesRotationsFrame@Rotations@CustomAbilitiesTabs@CustomAbilitiesFrame@Abilities@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg]:ClearItems  
        healHotRot:GetSettingIterator[abilIter]
        abilType:Set["bene"]
        break
      case healGrpRot
        UIElement[CustomRotList@CustomAbilitiesRotationsFrame@Rotations@CustomAbilitiesTabs@CustomAbilitiesFrame@Abilities@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg]:ClearItems  
        healGrpRot:GetSettingIterator[abilIter]
        abilType:Set["bene"]
        break
      case canniRot
        UIElement[CustomRotList@CustomAbilitiesRotationsFrame@Rotations@CustomAbilitiesTabs@CustomAbilitiesFrame@Abilities@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg]:ClearItems  
        canniRot:GetSettingIterator[abilIter]
        abilType:Set["all"]
        break
      case debuffRot
        UIElement[CustomRotList@CustomAbilitiesRotationsFrame@Rotations@CustomAbilitiesTabs@CustomAbilitiesFrame@Abilities@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg]:ClearItems  
        debuffRot:GetSettingIterator[abilIter]
        abilType:Set["detr"]
        break
      case meleeDebuffRot
        UIElement[CustomRotList@CustomAbilitiesRotationsFrame@Rotations@CustomAbilitiesTabs@CustomAbilitiesFrame@Abilities@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg]:ClearItems  
        meleeDebuffRot:GetSettingIterator[abilIter]
        abilType:Set["detr"]
        break
      case rangeDebuffRot
        UIElement[CustomRotList@CustomAbilitiesRotationsFrame@Rotations@CustomAbilitiesTabs@CustomAbilitiesFrame@Abilities@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg]:ClearItems  
        rangeDebuffRot:GetSettingIterator[abilIter]
        abilType:Set["detr"]
        break
      case dotRot
        UIElement[CustomRotList@CustomAbilitiesRotationsFrame@Rotations@CustomAbilitiesTabs@CustomAbilitiesFrame@Abilities@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg]:ClearItems  
        dotRot:GetSettingIterator[abilIter]
        abilType:Set["detr"]
        break
      case meleeDotRot
        UIElement[CustomRotList@CustomAbilitiesRotationsFrame@Rotations@CustomAbilitiesTabs@CustomAbilitiesFrame@Abilities@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg]:ClearItems  
        meleeDotRot:GetSettingIterator[abilIter]
        abilType:Set["detr"]
        break
      case rangeDotRot
        UIElement[CustomRotList@CustomAbilitiesRotationsFrame@Rotations@CustomAbilitiesTabs@CustomAbilitiesFrame@Abilities@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg]:ClearItems  
        rangeDotRot:GetSettingIterator[abilIter]
        abilType:Set["detr"]
        break
      case meleeRot
        UIElement[CustomRotList@CustomAbilitiesRotationsFrame@Rotations@CustomAbilitiesTabs@CustomAbilitiesFrame@Abilities@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg]:ClearItems  
        meleeRot:GetSettingIterator[abilIter]
        abilType:Set["detr"]
        break
      case rangeRot
        UIElement[CustomRotList@CustomAbilitiesRotationsFrame@Rotations@CustomAbilitiesTabs@CustomAbilitiesFrame@Abilities@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg]:ClearItems  
        rangeRot:GetSettingIterator[abilIter]
        abilType:Set["detr"]
        break
      case nukeRot
        UIElement[CustomRotList@CustomAbilitiesRotationsFrame@Rotations@CustomAbilitiesTabs@CustomAbilitiesFrame@Abilities@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg]:ClearItems  
        nukeRot:GetSettingIterator[abilIter]
        abilType:Set["detr"]
        break
      case reactRot
        UIElement[CustomRotList@CustomAbilitiesRotationsFrame@Rotations@CustomAbilitiesTabs@CustomAbilitiesFrame@Abilities@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg]:ClearItems  
        reactRot:GetSettingIterator[abilIter]
        abilType:Set["detr"]
        break
      case AERot
        UIElement[CustomRotList@CustomAbilitiesRotationsFrame@Rotations@CustomAbilitiesTabs@CustomAbilitiesFrame@Abilities@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg]:ClearItems  
        AERot:GetSettingIterator[abilIter]
        abilType:Set["all"]
        break
      case rescueRot
        UIElement[CustomRotList@CustomAbilitiesRotationsFrame@Rotations@CustomAbilitiesTabs@CustomAbilitiesFrame@Abilities@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg]:ClearItems  
        rescueRot:GetSettingIterator[abilIter]
        abilType:Set["all"]
        break
      case burnRot
        UIElement[CustomRotList@CustomAbilitiesRotationsFrame@Rotations@CustomAbilitiesTabs@CustomAbilitiesFrame@Abilities@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg]:ClearItems  
        burnRot:GetSettingIterator[abilIter]
        abilType:Set["detr"]
        break
      case burnBuffRot
        UIElement[CustomRotList@CustomAbilitiesRotationsFrame@Rotations@CustomAbilitiesTabs@CustomAbilitiesFrame@Abilities@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg]:ClearItems  
        burnBuffRot:GetSettingIterator[abilIter]
        abilType:Set["bene"]
        break
      case evasiveRot
        UIElement[CustomRotList@CustomAbilitiesRotationsFrame@Rotations@CustomAbilitiesTabs@CustomAbilitiesFrame@Abilities@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg]:ClearItems  
        evasiveRot:GetSettingIterator[abilIter]
        abilType:Set["all"]
        break
      case pullRot
        UIElement[CustomRotList@CustomAbilitiesRotationsFrame@Rotations@CustomAbilitiesTabs@CustomAbilitiesFrame@Abilities@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg]:ClearItems  
        pullRot:GetSettingIterator[abilIter]
        abilType:Set["detr"]
        break
      case specPtsRot
        UIElement[CustomRotList@CustomAbilitiesRotationsFrame@Rotations@CustomAbilitiesTabs@CustomAbilitiesFrame@Abilities@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg]:ClearItems  
        specPtsRot:GetSettingIterator[abilIter]
        abilType:Set["all"]
        break
      case noGCDList
        UIElement[CustomRotList@CustomAbilitiesRotationsFrame@Rotations@CustomAbilitiesTabs@CustomAbilitiesFrame@Abilities@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg]:ClearItems  
        noGCDList:GetSettingIterator[abilIter]
        abilType:Set["all"]
        break
      case hateToTankRot
        UIElement[CustomRotList@CustomAbilitiesRotationsFrame@Rotations@CustomAbilitiesTabs@CustomAbilitiesFrame@Abilities@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg]:ClearItems  
        hateToTankRot:GetSettingIterator[abilIter]
        abilType:Set["detr"]
        break
      case AEHateToTankRot
        UIElement[CustomRotList@CustomAbilitiesRotationsFrame@Rotations@CustomAbilitiesTabs@CustomAbilitiesFrame@Abilities@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg]:ClearItems  
        AEHateToTankRot:GetSettingIterator[abilIter]
        abilType:Set["detr"]
        break
      case DTgtDeaggroRot
        UIElement[CustomRotList@CustomAbilitiesRotationsFrame@Rotations@CustomAbilitiesTabs@CustomAbilitiesFrame@Abilities@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg]:ClearItems  
        DTgtDeaggroRot:GetSettingIterator[abilIter]
        abilType:Set["detr"]
        break
      case bene
        abilType:Set["bene"]
        break
      case detr
        abilType:Set["detr"]
        break
      case all
        abilType:Set["all"]
        break
  }
  if ${abilIter:First(exists)}
  {
    do
    {
      ;echo ${abilIter.Key} - ${abilIter.Value}
      UIElement[CustomRotList@CustomAbilitiesRotationsFrame@Rotations@CustomAbilitiesTabs@CustomAbilitiesFrame@Abilities@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg]:AddItem[${abilIter.Value}]  
    }
    while ${abilIter:Next(exists)}
  }

  if ${abilType.Equal[detr]}
  {
    ;echo --- populating abil UI drop down boxes, requires offensive tgt
    for (iterCnt:Set[1] ; ${iterCnt} <= ${Me.Ability} ; iterCnt:Inc)
    {
      if ${Me.Ability[${iterCnt}].TargetType.Equal[Offensive]}
        UIElement[CustomAbilCombo@CustomAbilitiesRotationsFrame@Rotations@CustomAbilitiesTabs@CustomAbilitiesFrame@Abilities@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg]:AddItem[${Me.Ability[${iterCnt}].Name}]
    }
  }
  elseif ${abilType.Equal[bene]}
  {
    ;echo --- populating abil UI drop down boxes, requires self, defensive or ally tgt
    for (iterCnt:Set[1] ; ${iterCnt} <= ${Me.Ability} ; iterCnt:Inc)
    {
      if ${Me.Ability[${iterCnt}].TargetType.Equal[Defensive]} || ${Me.Ability[${iterCnt}].TargetType.Equal[Self]} || ${Me.Ability[${iterCnt}].TargetType.Equal[Ally]} || ${Me.Ability[${iterCnt}].TargetType.Equal[Group]} || ${Me.Ability[${iterCnt}].TargetType.Equal[Your Group]}
        UIElement[CustomAbilCombo@CustomAbilitiesRotationsFrame@Rotations@CustomAbilitiesTabs@CustomAbilitiesFrame@Abilities@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg]:AddItem[${Me.Ability[${iterCnt}].Name}]
    }
  }
  elseif ${abilType.Equal[all]}
  {
    ;echo --- populating item UI drop down boxes, all included
    for (iterCnt:Set[1] ; ${iterCnt} <= ${Me.Ability} ; iterCnt:Inc)
    {
      UIElement[CustomAbilCombo@CustomAbilitiesRotationsFrame@Rotations@CustomAbilitiesTabs@CustomAbilitiesFrame@Abilities@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg]:AddItem[${Me.Ability[${iterCnt}].Name}]
    }
    if ${Me.HavePet}
    {
      for (iterCnt:Set[1] ; ${iterCnt} <= ${Me.Pet.Ability} ; iterCnt:Inc)
      {
        UIElement[CustomAbilCombo@CustomAbilitiesRotationsFrame@Rotations@CustomAbilitiesTabs@CustomAbilitiesFrame@Abilities@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg]:AddItem[${Me.Pet.Ability[${iterCnt}].Name}]
      }
    }
  }
}

atom(script) CustomAbilRotSave()
{
  variable int iterCnt
  ;echo saving custom ability rotation -- ${UIElement[CustomRotCombo@CustomAbilitiesRotationsFrame@Rotations@CustomAbilitiesTabs@CustomAbilitiesFrame@Abilities@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg].SelectedItem} -- ${UIElement[CustomRotList@CustomAbilitiesRotationsFrame@Rotations@CustomAbilitiesTabs@CustomAbilitiesFrame@Abilities@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg].Items}
  LavishSettings[ezvg].FindSet[${UIElement[CustomRotCombo@CustomAbilitiesRotationsFrame@Rotations@CustomAbilitiesTabs@CustomAbilitiesFrame@Abilities@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg].SelectedItem}]:Clear
  for (iterCnt:Set[1] ; ${iterCnt}<=${UIElement[CustomRotList@CustomAbilitiesRotationsFrame@Rotations@CustomAbilitiesTabs@CustomAbilitiesFrame@Abilities@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg].Items} ; iterCnt:Inc)
  {
    ;echo ${iterCnt} -- ${UIElement[CustomRotList@CustomAbilitiesRotationsFrame@Rotations@CustomAbilitiesTabs@CustomAbilitiesFrame@Abilities@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg].OrderedItem[${iterCnt}]}
    LavishSettings[ezvg].FindSet[${UIElement[CustomRotCombo@CustomAbilitiesRotationsFrame@Rotations@CustomAbilitiesTabs@CustomAbilitiesFrame@Abilities@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg].SelectedItem}]:AddSetting[${UIElement[CustomRotList@CustomAbilitiesRotationsFrame@Rotations@CustomAbilitiesTabs@CustomAbilitiesFrame@Abilities@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg].OrderedItem[${iterCnt}]}, ${UIElement[CustomRotList@CustomAbilitiesRotationsFrame@Rotations@CustomAbilitiesTabs@CustomAbilitiesFrame@Abilities@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg].OrderedItem[${iterCnt}]}]
  }
  call xmlSave
  call xmlPrep
}

atom(script) CustomItemsRotSelection(string itemRot)
{
  UIElement[CustomItemsCombo@CustomItemsRotationsFrame@ItemsRotations@CustomItemsTabs@CustomItemsFrame@Items@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg]:ClearItems
  UIElement[CustomItemsRotList@CustomItemsRotationsFrame@ItemsRotations@CustomItemsTabs@CustomItemsFrame@Items@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg]:ClearItems  
  variable iterator itemIter
  variable string itemType
  variable int iterCnt
  switch ${itemRot}
  {
      case itemBuffRot
        itemBuffRot:GetSettingIterator[itemIter]
        itemType:Set["hotKey"]
        break
      case burnItemBuffRot
        burnItemBuffRot:GetSettingIterator[itemIter]
        itemType:Set["hotKey"]
        break
      case burnConsumableItemBuffRot
        burnConsumableItemBuffRot:GetSettingIterator[itemIter]
        itemType:Set["hotKey"]
        break
      case itemCanniRot
        itemCanniRot:GetSettingIterator[itemIter]
        itemType:Set["hotKey"]
        break
      case itemAssistRot
        itemAssistRot:GetSettingIterator[itemIter]
        itemType:Set["hotKey"]
        break
      case itemTankRot
        itemTankRot:GetSettingIterator[itemIter]
        itemType:Set["hotKey"]
        break
      case itemOTgtRot
        itemOTgtRot:GetSettingIterator[itemIter]
        itemType:Set["hotKey"]
        break
      case invTrash
        LavishSettings[ItemsDict].FindSet[invTrash]:GetSettingIterator[itemIter]
        itemType:Set["advInv"]
        break
      case lootOnly
        LavishSettings[ItemsDict].FindSet[lootOnly]:GetSettingIterator[itemIter]
        itemType:Set["advInv"]
        break
  }
  if ${itemIter:First(exists)}
  {
    do
    {
      ;echo ${itemIter.Key} - ${itemIter.Value}
      UIElement[CustomItemsRotList@CustomItemsRotationsFrame@ItemsRotations@CustomItemsTabs@CustomItemsFrame@Items@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg]:AddItem[${itemIter.Value}]  
    }
    while ${itemIter:Next(exists)}
  }
  if ${itemType.Equal[hotKey]}
  {
    ;echo --- populating item UI drop down boxes, requires hotkey
    for (iterCnt:Set[1] ; ${iterCnt} <= ${Me.Inventory} ; iterCnt:Inc)
    {
      if ${Me.Inventory[${iterCnt}].IsHotkeyed}
        UIElement[CustomItemsCombo@CustomItemsRotationsFrame@ItemsRotations@CustomItemsTabs@CustomItemsFrame@Items@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg]:AddItem[${Me.Inventory[${iterCnt}].Name}]
    }
  }
  elseif ${itemType.Equal[advInv]}
  {
    ;echo --- populating item UI drop down boxes, all included
    for (iterCnt:Set[1] ; ${iterCnt} <= ${Me.Inventory} ; iterCnt:Inc)
    {
      UIElement[CustomItemsCombo@CustomItemsRotationsFrame@ItemsRotations@CustomItemsTabs@CustomItemsFrame@Items@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg]:AddItem[${Me.Inventory[${iterCnt}].Name}]
    }
  }
}

atom(script) CustomItemsRotSave()
{
  variable string itemKey
  variable string itemFromCnt
  variable int iterCnt
  ;echo saving custom item rotation -- ${UIElement[CustomItemsRotCombo@CustomItemsRotationsFrame@ItemsRotations@CustomItemsTabs@CustomItemsFrame@Items@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg].SelectedItem} -- ${UIElement[CustomItemsRotList@CustomItemsRotationsFrame@ItemsRotations@CustomItemsTabs@CustomItemsFrame@Items@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg].Items}
  itemKey:Set[${UIElement[CustomItemsRotCombo@CustomItemsRotationsFrame@ItemsRotations@CustomItemsTabs@CustomItemsFrame@Items@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg].SelectedItem.Text}]
  echo ~~~ item save list ~~~~ ${itemKey}
  if ${itemKey.Equal[invTrash]} || ${itemKey.Equal[lootOnly]}
    LavishSettings[ItemsDict].FindSet[${itemKey}]:Clear
  else 
    LavishSettings[ezvg].FindSet[${itemKey}]:Clear
  for (iterCnt:Set[1] ; ${iterCnt}<=${UIElement[CustomItemsRotList@CustomItemsRotationsFrame@ItemsRotations@CustomItemsTabs@CustomItemsFrame@Items@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg].Items} ; iterCnt:Inc)
  {
    ;echo ${iterCnt} -- ${UIElement[CustomItemsRotList@CustomItemsRotationsFrame@ItemsRotations@CustomItemsTabs@CustomItemsFrame@Items@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg].OrderedItem[${iterCnt}]}
    itemFromCnt:Set[${UIElement[CustomItemsRotList@CustomItemsRotationsFrame@ItemsRotations@CustomItemsTabs@CustomItemsFrame@Items@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg].OrderedItem[${iterCnt}]}]
    if ${itemKey.Equal[invTrash]} || ${itemKey.Equal[lootOnly]}
    {
      if !${LavishSettings[ItemsDict].FindSet[${itemKey}](exists)}
        LavishSettings[ItemsDict]:AddSet[${itemKey}]
      LavishSettings[ItemsDict].FindSet[${itemKey}]:AddSetting[${itemFromCnt}, ${itemFromCnt}]
    }
    else
    {
      if !${LavishSettings[ezvg].FindSet[${itemKey}](exists)}
        LavishSettings[ezvg]:AddSet[${itemKey}]
      LavishSettings[ezvg].FindSet[${itemKey}]:AddSetting[${itemFromCnt}, ${itemFromCnt}]
    }
  }
  call xmlSave
  call xmlPrep
}

atom(script) CustomAbilityTimerSelection(string abilName)
{
  ;echo CustomAbilityTimerSelection ${abilName}
  ; first delete any options chosen in the timer (if they exist)
  UIElement[CustomTimerCombo@CustomAbilitiesSpellLinesFrame@Spell Lines and Timers@CustomAbilitiesTabs@CustomAbilitiesFrame@Abilities@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg]:ClearItems
  variable int iterCnt
  for (iterCnt:Set[10] ; ${iterCnt}<=60 ; iterCnt:Inc)
  {
    UIElement[CustomTimerCombo@CustomAbilitiesSpellLinesFrame@Spell Lines and Timers@CustomAbilitiesTabs@CustomAbilitiesFrame@Abilities@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg]:AddItem[${iterCnt}]
    if ${LavishSettings[AbilDict].FindSet[${Me.Class}].FindSet[TIMERS].FindSetting[${abilName}](exists)}
    {
      ;okay so the data all ready exists, is it the same as iterCnt?
      if ${iterCnt.Equal[${LavishSettings[AbilDict].FindSet[${Me.Class}].FindSet[TIMERS].FindSetting[${abilName}]}]}
        UIElement[CustomTimerCombo@CustomAbilitiesSpellLinesFrame@Spell Lines and Timers@CustomAbilitiesTabs@CustomAbilitiesFrame@Abilities@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg]:SetSelection[${UIElement[CustomTimerCombo@CustomAbilitiesSpellLinesFrame@Spell Lines and Timers@CustomAbilitiesTabs@CustomAbilitiesFrame@Abilities@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg].Items}]
    }
  }
  for (iterCnt:Set[90] ; ${iterCnt}<=3600 ; iterCnt:Inc[30])
  {
    UIElement[CustomTimerCombo@CustomAbilitiesSpellLinesFrame@Spell Lines and Timers@CustomAbilitiesTabs@CustomAbilitiesFrame@Abilities@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg]:AddItem[${iterCnt}]
    if ${LavishSettings[AbilDict].FindSet[${Me.Class}].FindSet[TIMERS].FindSetting[${abilName}](exists)}
    {
      ;okay so the data all ready exists, is it the same as iterCnt?
      if ${iterCnt.Equal[${LavishSettings[AbilDict].FindSet[${Me.Class}].FindSet[TIMERS].FindSetting[${abilName}]}]}
        UIElement[CustomTimerCombo@CustomAbilitiesSpellLinesFrame@Spell Lines and Timers@CustomAbilitiesTabs@CustomAbilitiesFrame@Abilities@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg]:SetSelection[${UIElement[CustomTimerCombo@CustomAbilitiesSpellLinesFrame@Spell Lines and Timers@CustomAbilitiesTabs@CustomAbilitiesFrame@Abilities@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg].Items}]
    }
  }

}

atom(script) CustomTimerSelection(string abilName, int abilTimer, string action)
{
  ;echo CustomTimerSelection ${abilName} ${abilTimer} ${action}
  if !${Me.Ability[${abilName}](exists)} || ${abilTimer}<10
    return
  if !${LavishSettings[AbilDict].FindSet[${Me.Class}](exists)}
  {
    ;echo CustomTimerSelection ... class didn't exist, making the set now
    LavishSettings[AbilDict]:AddSet[${Me.Class}]
  }
  if !${LavishSettings[AbilDict].FindSet[${Me.Class}].FindSet[TIMERS](exists)}
  {
    ;echo CustomTimerSelection ... TIMERS set didn't exist, making it now
    LavishSettings[AbilDict].FindSet[${Me.Class}]:AddSet[TIMERS]
  }
  if ${action.Equal[add]}
  {
    ;echo does the TIMER set exist with the setting? ${LavishSetting[AbilDict].FindSet[${Me.Class}].FindSet[TIMERS].FindSetting[${abilName}](exists)} 
    if ${LavishSettings[AbilDict].FindSet[${Me.Class}].FindSet[TIMERS].FindSetting[${abilName}](exists)}
      LavishSettings[AbilDict].FindSet[${Me.Class}].FindSet[TIMERS].FindSetting[${abilName}]:Set[${abilTimer}]
    else
      LavishSettings[AbilDict].FindSet[${Me.Class}].FindSet[TIMERS]:AddSetting[${abilName}, ${abilTimer}]
  }
}

atom(script) CustomSpellLineSelection(string spellLine)
{
  UIElement[CustomSpellLineList@CustomAbilitiesSpellLinesFrame@Spell Lines and Timers@CustomAbilitiesTabs@CustomAbilitiesFrame@Abilities@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg]:ClearItems
  variable iterator spellLineIter
  variable int iterCnt
  LavishSettings[AbilDict].FindSet[${Me.Class}].FindSet[${spellLine}]:GetSettingIterator[spellLineIter]
  if ${spellLineIter:First(exists)}
  {
    do
    {
      ;echo ${spellLineIter.Key} - ${spellLineIter.Value}
      UIElement[CustomSpellLineList@CustomAbilitiesSpellLinesFrame@Spell Lines and Timers@CustomAbilitiesTabs@CustomAbilitiesFrame@Abilities@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg]:AddItem[${spellLineIter.Value}]  
    }
    while ${spellLineIter:Next(exists)}
  }
}

atom(script) CustomSpellLineSave(string abilName)
{
  ;echo adding ${abilName} to ${UIElement[CustomSpellLineCombo@CustomAbilitiesSpellLinesFrame@Spell Lines and Timers@CustomAbilitiesTabs@CustomAbilitiesFrame@Abilities@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg].SelectedItem}
  if !${UIElement[CustomSpellLineCombo@CustomAbilitiesSpellLinesFrame@Spell Lines and Timers@CustomAbilitiesTabs@CustomAbilitiesFrame@Abilities@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg].SelectedItem(exists)}
    return
  if !${LavishSettings[AbilDict].FindSet[${Me.Class}](exists)}
    LavishSettings[AbilDict]:AddSet[${Me.Class}]
  if !${LavishSettings[AbilDict].FindSet[${Me.Class}].FindSet[${UIElement[CustomSpellLineCombo@CustomAbilitiesSpellLinesFrame@Spell Lines and Timers@CustomAbilitiesTabs@CustomAbilitiesFrame@Abilities@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg].SelectedItem}](exists)}
    LavishSettings[AbilDict].FindSet[${Me.Class}]:AddSet[${UIElement[CustomSpellLineCombo@CustomAbilitiesSpellLinesFrame@Spell Lines and Timers@CustomAbilitiesTabs@CustomAbilitiesFrame@Abilities@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg].SelectedItem}]
  LavishSettings[AbilDict].FindSet[${Me.Class}].FindSet[${UIElement[CustomSpellLineCombo@CustomAbilitiesSpellLinesFrame@Spell Lines and Timers@CustomAbilitiesTabs@CustomAbilitiesFrame@Abilities@CustomTabs@CustomFrame@Custom@EZVGTabs@ezvg].SelectedItem}]:AddSetting[${abilName}, ${abilName}]
}

atom(script) HaxPortList()
{
  variable int iterCnt
  ;echo adding port locations to dropdown
  UIElement[HaxLocCombo@HaxFrame@Hax@EZVGTabs@ezvg]:ClearItems
  for (iterCnt:Set[1] ; ${iterCnt}<=${ISXVG.VGLocsCount} ; iterCnt:Inc )
  {
    if ${Me.Chunk.X.Equal[${VGLoc[${iterCnt}].ChunkX}]} && ${Me.Chunk.Y.Equal[${VGLoc[${iterCnt}].ChunkY}]}
      UIElement[HaxLocCombo@HaxFrame@Hax@EZVGTabs@ezvg]:AddItem[${VGLoc[${iterCnt}]}] 
  }
}

atom(script) HaxPortTo()
{
  ;echo --- attempting to port to ${UIElement[HaxLocCombo@HaxFrame@Hax@EZVGTabs@ezvg].SelectedItem}
  if !${UIElement[HaxLocCombo@HaxFrame@Hax@EZVGTabs@ezvg].SelectedItem.Text(exists)}
    return
  VGLoc[${UIElement[HaxLocCombo@HaxFrame@Hax@EZVGTabs@ezvg].SelectedItem.Text}]:Port
}

atom(script) WSVarSelect(string wpnSet)
{
  variable string tempTxt
  ;echo --- selected WS var ${wpnSet}
  UIElement[WSPrimaryValue@OptionsItemsFrame@Items@OptionsTabs@OptionsFrame@Options@EZVGTabs@ezvg]:SetText[]
  UIElement[WSOffhandValue@OptionsItemsFrame@Items@OptionsTabs@OptionsFrame@Options@EZVGTabs@ezvg]:SetText[]
  UIElement[WSRangedValue@OptionsItemsFrame@Items@OptionsTabs@OptionsFrame@Options@EZVGTabs@ezvg]:SetText[]
  if !${LavishSettings[ezvg].FindSet[WeaponSets].FindSet[${wpnSet}](exists)}
    return
  if ${LavishSettings[ezvg].FindSet[WeaponSets].FindSet[${wpnSet}].FindSetting[primary](exists)}
  {
    tempTxt:Set[${LavishSettings[ezvg].FindSet[WeaponSets].FindSet[${wpnSet}].FindSetting[primary]}]
    UIElement[WSPrimaryValue@OptionsItemsFrame@Items@OptionsTabs@OptionsFrame@Options@EZVGTabs@ezvg]:SetText[${tempTxt.Replace["#", " "]}]
  }
  if ${LavishSettings[ezvg].FindSet[WeaponSets].FindSet[${wpnSet}].FindSetting[offhand](exists)}
  {
    tempTxt:Set[${LavishSettings[ezvg].FindSet[WeaponSets].FindSet[${wpnSet}].FindSetting[offhand]}]
    UIElement[WSOffhandValue@OptionsItemsFrame@Items@OptionsTabs@OptionsFrame@Options@EZVGTabs@ezvg]:SetText[${tempTxt.Replace["#", " "]}]
  }
  if ${LavishSettings[ezvg].FindSet[WeaponSets].FindSet[${wpnSet}].FindSetting[ranged](exists)}
  {
    tempTxt:Set[${LavishSettings[ezvg].FindSet[WeaponSets].FindSet[${wpnSet}].FindSetting[ranged]}]
    UIElement[WSRangedValue@OptionsItemsFrame@Items@OptionsTabs@OptionsFrame@Options@EZVGTabs@ezvg]:SetText[${tempTxt.Replace["#", " "]}]
  }
}

atom(script) WSSet(string wpnSet)
{
  ;echo --- setting WS var ${wpnSet}
  UIElement[WSPrimaryValue@OptionsItemsFrame@Items@OptionsTabs@OptionsFrame@Options@EZVGTabs@ezvg]:SetText[]
  UIElement[WSOffhandValue@OptionsItemsFrame@Items@OptionsTabs@OptionsFrame@Options@EZVGTabs@ezvg]:SetText[]
  UIElement[WSRangedValue@OptionsItemsFrame@Items@OptionsTabs@OptionsFrame@Options@EZVGTabs@ezvg]:SetText[]
  if ${LavishSettings[ezvg].FindSet[WeaponSets].FindSet[${wpnSet}](exists)}
    LavishSettings[ezvg].FindSet[WeaponSets].FindSet[${wpnSet}]:Remove
  LavishSettings[ezvg].FindSet[WeaponSets]:AddSet[${wpnSet}]
  if ${Me.Inventory[CurrentEquipSlot, "Two Hands"](exists)}
  {
    LavishSettings[ezvg].FindSet[WeaponSets].FindSet[${wpnSet}]:AddSetting[primary, ${Me.Inventory[CurrentEquipSlot, Two Hands].Name.Replace[",", "#"]}]
    UIElement[WSPrimaryValue@OptionsItemsFrame@Items@OptionsTabs@OptionsFrame@Options@EZVGTabs@ezvg]:SetText[${Me.Inventory[CurrentEquipSlot, "Two Hands"].Name.Replace[", "," "]}]
  }
  else
  {
    if ${Me.Inventory[CurrentEquipSlot, "Primary Hand"](exists)}
    {
      LavishSettings[ezvg].FindSet[WeaponSets].FindSet[${wpnSet}]:AddSetting[primary, ${Me.Inventory[CurrentEquipSlot, Primary Hand].Name.Replace[",", "#"]}]
      UIElement[WSPrimaryValue@OptionsItemsFrame@Items@OptionsTabs@OptionsFrame@Options@EZVGTabs@ezvg]:SetText[${Me.Inventory[CurrentEquipSlot, "Primary Hand"].Name.Replace[", "," "]}]
    }
    if ${Me.Inventory[CurrentEquipSlot, "Secondary Hand"](exists)}
    {
      LavishSettings[ezvg].FindSet[WeaponSets].FindSet[${wpnSet}]:AddSetting[offhand, ${Me.Inventory[CurrentEquipSlot, Secondary Hand].Name.Replace[",", "#"]}]
      UIElement[WSOffhandValue@OptionsItemsFrame@Items@OptionsTabs@OptionsFrame@Options@EZVGTabs@ezvg]:SetText[${Me.Inventory[CurrentEquipSlot, "Secondary Hand"].Name.Replace[", "," "]}]
    }
  }
  if ${Me.Inventory[CurrentEquipSlot, "Ranged"](exists)}
  {
    LavishSettings[ezvg].FindSet[WeaponSets].FindSet[${wpnSet}]:AddSetting[ranged, ${Me.Inventory[CurrentEquipSlot, Ranged].Name.Replace[",", "#"]}]
    UIElement[WSRangedValue@OptionsItemsFrame@Items@OptionsTabs@OptionsFrame@Options@EZVGTabs@ezvg]:SetText[${Me.Inventory[CurrentEquipSlot, "Ranged"].Name.Replace[", "," "]}]
  }
}

atom(script) WSClear(string wpnSet)
{
  ;echo --- clearing WS var ${wpnSet}
  LavishSettings[ezvg].FindSet[WeaponSets].FindSet[${wpnSet}]:Remove
  UIElement[WSPrimaryValue@OptionsItemsFrame@Items@OptionsTabs@OptionsFrame@Options@EZVGTabs@ezvg]:SetText[]
  UIElement[WSOffhandValue@OptionsItemsFrame@Items@OptionsTabs@OptionsFrame@Options@EZVGTabs@ezvg]:SetText[]
  UIElement[WSRangedValue@OptionsItemsFrame@Items@OptionsTabs@OptionsFrame@Options@EZVGTabs@ezvg]:SetText[]
  
}

